# -*- coding: utf-8 -*-

class ProductsController < ApplicationController
  def index
    @title = "銘柄検索"
    @subtitle = "読みまたは漢字を入力してください。途中まででも可。"
  end

  def search
    session[:search_select] = "yomi"
    @products = Product.find(:all, :conditions => ["is_show = true and (name_yomi like ? or name like ?)", "#{params[:product_name]}%", "#{params[:product_name]}%"])

    @title = "銘柄検索"
    @subtitle = params[:product_name]
  end
  
  def detail
    @product = Product.where(:id => params[:id], :is_show => true).first
    @keywords = Keyword.where(:product => params[:id]).all
    @temperatures = Temperature.where(:product => params[:id]).all
    @impressions = Impression.where(:product => params[:id]).all

    @title = "銘柄詳細"
    @subtitle = @product.name + "（" + @product.name_yomi + "）の紹介"
  end
end
